<?php
$ma = (isset($m_ativo)) ? $m_ativo : 'home';
$menus = [];
$sm_academico = [["href" => './coordenacao/grade/avaliar/', "text" => 'Avaliar grades', "sm" => 'grade'],
    ["href" => './academico/requerimento/', "text" => 'Requerimentos', "sm" => 'requerimento']];
$sm_gerenciar = [["href" => './gerenciar/manter/coordenador/', "text" => 'Coordenadores', "sm" => 'crd'],
    ["href" => './gerenciar/manter/professor/', "text" => 'Professores', "sm" => 'prof'],
    ["href" => './gerenciar/manter/curso/', "text" => 'Cursos', "sm" => 'curso'],
    ["href" => './gerenciar/manter/disciplina/', "text" => 'Disciplinas', "sm" => 'dcp'],
    ["href" => './gerenciar/manter/turma/', "text" => 'Turmas', "sm" => 'turma']];
$menus['home'] = array("href" => './', "class" => 'home', "text" => 'Principal', "submenu" => []);
$menus['academico'] = array("href" => '#', "class" => 'academico', "text" => 'Acadêmico', "submenu" => $sm_academico);
$menus['gerenciar'] = array("href" => '#', "class" => 'gerenciar', "text" => 'Gerenciar', "submenu" => $sm_gerenciar);
$menus['configuracoes'] = array("href" => './faqs/', "class" => 'faqs', "text" => 'Perguntas frequentes', "submenu" => []);
$menus['sobre'] = array("href" => './sobreosonic', "class" => 'matricula', "text" => 'Sobre o SONIC', "submenu" => []);
?>
<div class="menu_control"><i class="icon-reorder"></i></div>
<div id="menu_lateral">
    <nav>
        <ul class="m-top">
            <?php
            foreach ($menus as $menu) {
                $classes = array();
                $sbm = count($menu['submenu']);
                $classes['submenu'] = ($sbm) ? 'c-sub' : 'no-sub';
                $classes['menu'] = ($menu['class'] == $ma) ? 'm-ativo' : 'm-link';
                $cl_menu = ' class="'. implode(' ', $classes) . '"';
                echo '<li' . $cl_menu . '><a href="' . $menu["href"] . '" class="' . $menu['class'] . '"><span>' . $menu["text"] . '</span></a>';
                if ($sbm) {
                    echo '<ul class="m-sub">';
                    foreach ($menu['submenu'] as $sm) {
                        $sma = (isset($sm_ativo)) ? $sm_ativo : 'none';
                        $cl_smenu = ($sm['sm'] == $sma) ? ' class="sm-ativo"' : '';
                        echo '<li'. $cl_smenu .'><a href="' . $sm['href'] . '">' . $sm['text'] . '</a></li>';
                    }
                    echo '</ul>';
                }
                echo '</li>';
            }
            ?>
        </ul>
    </nav>
</div>